
<template>
  <div class="complaint-main" id="complaint-main">
    <div class="complaint-step">
      <span><img src="../../../static/imgs/bian_02.png" alt="" title=""/></span>
      <span>申诉类型</span>
      <select name="" id="" class="type" @change="changeType">
        <option value="1">操作问题</option>
        <option value="1">返回问题</option>
        <option value="1">其他问题</option>

      </select>
    </div>
    <div class="complaint-border"></div>
    <div class="complaint-con">
      <div class="complaint-box">
        <!--<div class="complaint-t">-->
          <!--<span><img src="../../../static/imgs/bian_02.png" alt="" title=""/></span>-->
          <!--<span>第一步</span>-->
          <!--<span>收货好评</span>-->
        <!--</div>-->
        <p>评价及物流截图</p>
        <div class="complaint-list">
          <ul flex="main:justify">
            <li>
              <div class="complaint-list-t">
                申诉截图1
              </div>
              <div class="complaint-list-img">
                <div class="list-img-box">
                  <input type="file" @change="upload(arguments,'picture1')">
                  <img :src="submit.picture1?imgUrl(submit.picture1):'static/imgs/addtupian01.png'" alt="" title=""/>
                </div>
              </div>

            </li>
            <li>
              <div class="complaint-list-t">
                申诉截图2
              </div>
              <div class="complaint-list-img">
                <div class="list-img-box" @change="upload(arguments,'picture2')">
                  <input type="file">
                  <img :src="submit.picture2?imgUrl(submit.picture2):'static/imgs/addtupian01.png'" alt="" title=""/>
                </div>
              </div>
            </li>
            <li>
              <div class="complaint-list-t">
                申诉截图3
              </div>
              <div class="complaint-list-img">
                <div class="list-img-box" @change="upload(arguments,'picture3')">
                  <input type="file">
                  <img :src="submit.picture3?imgUrl(submit.picture3):'static/imgs/addtupian01.png'" alt="" title=""/>
                </div>
              </div>
            </li>
            <li>
              <div class="complaint-list-t">
                申诉截图4
              </div>
              <div class="complaint-list-img">
                <div class="list-img-box" @change="upload(arguments,'picture4')">
                  <input type="file">
                  <img :src="submit.picture4?imgUrl(submit.picture4):'static/imgs/addtupian01.png'" alt="" title=""/>
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="complaint-border"></div>
    <div class="complaint-require clearfix">
      <p>申诉内容</p>
      <div class="complaint-text">
        <textarea v-model="submit.complainContent"> </textarea>
      </div>
    </div>
    <div class="complaint-border"></div>
    <div class="complaint-btn">
      <div class="complaint-btn-box">
        <a @click="submitInfo">提交评价</a>
        <router-link :to="{name:'orderDetails'}">
          返回任务列表
        </router-link>

      </div>
    </div>
  </div>
</template>


<script>
  import {baseService,taskService} from '#/service'
  import baseMixins from '../../mixins/base'
  export default{
    name:'complaint',
    data(){
      return {
        submit:{
          "buyerTaskId": "",
          "complainContent": "",
          "picture1": "",
          "picture2": "",
          "picture3": "",
          "picture4": "",
          type:"0"
        },
        result:{},
        rules:{
          complainContent:{
            rules:[
              {
                type:'inFun',
                rule:'required',
                msg:'投诉内容不能为空！'
              },
            ] ,
            value:'',
            join:'and'
          },
        }
      }
    },
    created(){
      this.submit.buyerTaskId=this.$route.query.buyTaskId
    },
    methods:{
      changeType($event){
        this.submit.type=$event.target.value
      },
      submitInfo(){
        this.$nextTick(()=>{
          this.result=this.$valiForm.form(this.rules);
          if(this.result.adopt){
            baseService.submitComplain({
              data:this.submit,
              success:()=>{
                this.$toast({
                  message: '提交成功',
                  position: 'middle',
                  duration: 800
                })
                setTimeout(()=>{
                  this.$router.push({
                    name:'orderDetails'
                  })
                },1000)
              }
            })

          }else{
            let keys=Object.keys(this.result)
            for(let i=0;i<keys.length;i++){
              if(keys[i]!=='adopt'){
                this.$toast({
                  message: this.result[keys[i]].msg,
                  position: 'middle',
                  duration: 2000
                });
                return
              }
            }
          }
        })

      }
    },
    watch:{
      'submit.complainContent':{
        immediate:true,
        handler(newVal){
          this.rules.complainContent.value=newVal
        },
      }
    },
    mixins:[baseMixins]
  }
</script>
<style lang="less" scoped>
  #complaint-main{
    .complaint-text{
      height: auto;
    }
    textarea{
      display: block;
      width: 90%;
      margin: 0.1rem auto;
      font-size: 0.14rem;
      height: 1rem;
      padding: 0.1rem;
    }
    .type{
      clear: both;
      font-size: 0.14rem;
      display: block;
      height: 0.4rem;
      margin: 0.1rem 0.1rem 0 0.1rem;
    }
  }
</style>
<style scoped>

  .complaint-btn{
    width: 100%;
    height: 0.6rem;
    float:left;
    margin-top: 0.1rem;
  }
  .complaint-btn-box{
    width: 60%;
    margin: 0 auto;
    overflow: hidden;
  }
  .complaint-btn-box a{
    width: 1.04rem;
    height: 0.4rem;
    background: rgb(142,10,190);
    display: block;
    float:Left;
    line-height: 0.4rem;
    text-align: center;
    color: white;
    font-size: 0.12rem;
    cursor: pointer;
  }
  .complaint-btn-box a:last-child{
    background: #333;
    margin-left: 0.1rem;
  }
  .complaint-require{
    width: 100%;
    height: auto;
    float:left;
  }
  .complaint-require p{
    width:100%;
    height: 0.4rem;
    color: red;
    border-bottom: 0.01rem solid #e6e6e6;
    font-size: 0.14rem;
    line-height: 0.4rem;
  }
  .complaint-text{
    width: 100%;
    float:left;
    margin-top:0.1rem;
  }
  .complaint-text span{
    display: block;
    float:left;
    color: #333;
    font-size: 0.12rem;
  }
  .complaint-text span:last-child{
    color: red;
  }
  .select-img{
    width: 1rem;
    height: 0.32rem;
    line-height: 0.32rem;
    background: red;
  }
  .select-btn{
    width: 80%;
    margin: 0 auto;
  }
  .select-btn a{
    display: block;
    float:left;
    color: white;
    font-size: 0.12rem;
  }
  .select-btn a:first-child{
    width: 0.2rem;
    height: 0.2rem;
    margin: 0.05rem 0.05rem 0 0;
  }
  .select-btn a:first-child img{
    display: block;
    width: 100%;
  }
  .complaint-list .complaint-list-t{
    height: 0.4rem;
    line-height: 0.4rem;
    background: rgb(142,10,190);
    text-align: center;
    color: white;
    font-size: 0.13rem;
  }
  .complaint-list-img{
    width: 100%;
    margin: 0.05rem 0;
  }
  .list-img-box{
    height: 0.6rem;
    background: #e6e6e6;
    position: relative;
  }
  .list-img-box input{
    width: 1rem;
    height: 0.6rem;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    background: transparent;
  }
  .list-img-box img{
    display: block;
    width: 100%;
    height: 100%;
  }
  .complaint-box p{
    width: 100%;
    height:0.3rem;
    line-height: 0.3rem;
    color: #333;
    font-size: 0.14rem;
  }
  .complaint-list{
    width: 100%;
    float:left;
    height: auto;
  }
  .complaint-list ul li{
    width: 20%;
  }

  .complaint-con{
    width:100%;
    height: auto;
    float:left;
    margin-top: 0.1rem;
    padding-bottom: 0.1rem;
  }
  .complaint-box{
    width: 95%;
    margin: 0 auto;
  }
  .complaint-t{
    width: 100%;
    height: 0.4rem;
    line-height: 0.4rem;
    border-bottom: 0.4rem;
  }
  .complaint-t span{
    display: block;
    float: left;
    color: red;
    font-size: 0.13rem;
    margin-right: 0.1rem;
  }
  .complaint-t span:last-child{
    margin-right: inherit;
  }
  .complaint-t span:first-child{
    width: 0.2rem;
    height: 0.2rem;
    color: #26A2FF;
    margin-top: 0.1rem;
  }
  .complaint-t span:first-child img{
    display: block;
    width: 100%;
  }
  .complaint-border{
    width: 100%;
    height: 0.1rem;
    float: left;
    background: #f5f5f5;
  }
  .complaint-main{
    width: 100%;
    height: 100%;
    overflow: hidden;
  }
  .complaint-step{
    width:100%;
    line-height: 0.4rem;
    padding-bottom:0.1rem;
  }
  .complaint-step span{
    display: inline-block;
    float: left;
    color: #26A2FF;
    font-size: 0.14rem;
  }
  .complaint-step span:first-child{
    width: 0.2rem;
    height: 0.2rem;
    margin: 0.1rem 0.1rem 0 0.1rem;
  }
  .complaint-step span:first-child img{
    display: block;
    width: 100%;
  }
</style>
